package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 管理端-互动问题表 前端控制器
 * </p>
 * @author 陈彦祖
 * @since 2024-11-12
 */
@Api(tags = "管理端-互动问题表")
@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {
    private final IInteractionQuestionService questionService;

    /**1
     * 管理端分页查询互动问题列表
     * @param query
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("管理端分页查询互动问题列表")
    public PageDTO<QuestionAdminVO> pageQuestion(@RequestBody QuestionAdminPageQuery query) {
        return questionService.pageQuestion(query);
    }

    /**2
     * 管理端修改互动问题的隐藏状态
     * @param id
     * @param hidden
     */
    @PutMapping("/{id}/hidden/{hidden}")
    @ApiOperation("修改互动问题的隐藏状态")
    public void updateHidden(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden) {
        questionService.updateHidden(id, hidden);
    }

    /**3
     * 管理端根据id查询问题详情
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询问题详情")
    public QuestionAdminVO questionsQueryById(@PathVariable("id") Long id) {
        return questionService.questionsQueryById(id);
    }
}
